<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网格布局</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body,
        html {
            height: 100%;
            font-family: Arial, sans-serif;
        }

        .grid-container{
            display: grid;
            height: 100%;
            grid-template-areas:
                "header header header"
                "sidebar main main"
                "footer footer footer";
            grid-template-rows: auto 1fr auto;
            grid-template-columns: 200px 1fr 1fr;
            gap: 10px;
        }

        .header {
            grid-area: header;
            background: #333;
            color: #fff;
            padding: 20px;
            text-align: center;
        }

        .sidebar {
            grid-area: sidebar;
            background: #f4f4f4;
            padding: 20px;
        }

        .main {
            grid-area: main;
            background: #ddd;
            padding: 20px;
        }

        .footer {
            grid-area: footer;
            background: #333;
            color: #fff;
            text-align: center;
            padding: 20px;
        }

        @media (max-width: 600px) {
            .grid-container {
                grid-template-areas:
                    "header"
                    "main"
                    "sidebar"
                    "footer";
                grid-template-rows: auto 1fr auto auto;
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>

<body>

    <div class="grid-container">
        <div class="header">Header</div>
        <div class="sidebar">Sidebar</div>
        <div class="main">Main Content</div>
        <div class="footer">Footer</div>
    </div>

</body>

</html>